extends Node2D

onready var MAIN = find_parent("MAIN")
# Declare member variables here. Examples:
# var a: int = 2
# var b: String = "text"


func _process(delta: float) -> void:
	if MAIN.started:
		position.x += MAIN.speed * delta
		if position.x <= -100:
			if MAIN.delegation_hit:
				get_tree().change_scene("res://end3.tscn")
			else:
				get_tree().change_scene("res://end4.tscn")

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	$scaler/area.connect("body_entered",self,"on_hit")
	pass # Replace with function body.

func on_hit(_body):
	if MAIN.delegation_hit:
		get_tree().change_scene("res://end1.tscn")
	else:
		get_tree().change_scene("res://end2.tscn")

